<?
include("includes/functions.php");

if ($delete == 1) {
	// Don't actually delete, just switch Visible to 0
	$sql = "UPDATE ss_contact SET Visible = '0' WHERE ID = '$mID'";
	$result = mysql_db_query($dbname,$sql);
}

// Get all contact entries
$sql = "SELECT * from ss_contact WHERE Visible = '1' ORDER BY DateMessage DESC";
$result = mysql_db_query($dbname,$sql);
$rows = mysql_num_rows($result);

include("includes/header.php"); ?>
<script language="JavaScript">
function confirmSubmit(text) {
	var agree=confirm(text);
	if (agree)
		return true ;
	else
		return false ;
}
</script>
<div id="header2">
	<? include("includes/main_menu.php"); ?>
</div>
<? include("includes/sub_menu_maint.php"); ?>
<div id="subNoLogin"></div>
<div id="pageHeader"><h1 class="headerUsers">Website Maintenance : <b>General Contact Submissions</b></h1></div>

<div id="pageInstructions"><img src="images/help.gif"> <br><br>

<?
if (!empty($message)) { echo "<font color=red>$message</font>\n"; }
?>
<p></p>
</div>

<div id="datatable">
<table class="datatable" summary="A List of Current Admin Users">
	<caption>Current Messages [<?=$rows; ?>]</caption>
	
	<? if ($rows > 0) { ?>
	<tr>
		<th scope="col"></th>
		<th scope="col">Name</th>
		<th scope="col">Email</th>
		<th scope="col">Concerning</th>
		<th scope="col">Site Area</th>
		<th scope="col">Subject</th>
		<th scope="col">Date</th>
	</tr>
	<?
	$i = 0;
	while ($value = mysql_fetch_assoc($result)) {	
		if (($i % 2) > 0) { $class = "altrow"; $bgcolor = "#eeeeee"; }
		else { $class = null; $bgcolor = "#ffffff"; }
		
		$mID       = $value[ID];
		$uUID      = $value[UID];
		$name      = $value[Name];
  		$email     = $value[Email];
		$concerns  = $value[MessageConcerns];
  		$siteArea  = $value[SiteArea];
  		$subject   = stripslashes($value[Subject]);
  		$message   = stripslashes($value[Message]);
  		$date      = $value[DateMessage];
  		
  		if (strlen($uUserid) > 25) { $uUserid = substr($uUserid,0,25)."..."; }
  		if (strlen($uEmail) > 25) { $uEmail = substr($uEmail,0,25)."..."; }
  		
  		
	?>
	<tr class="<?=$class; ?>" onmouseover="setPointer(this, '#E9FCB2')" onmouseout="setPointer(this, '<?=$bgcolor; ?>')">
	
		<td class="nav">
			<a href="<?=$PHP_SELF; ?>?delete=1&mID=<?=$mID; ?>" onclick="return confirmSubmit('Are you sure you want to Delete this Message?');" title="Delete This Message"><img src="images/button_delete.gif" border="0"></a></td>
		<td><?=$name; ?></td>
		<td><a href="mailto:<?=$email; ?>"><?=$email; ?></a></td>
		<td><?=$concerns; ?></td>
		<td><?=$siteArea; ?></td>
		<td><?=$subject; ?></td>
		<td><? mysql_to_date($date); ?></td>
	</tr>
	<?  $i++; }
		} else { ?>
	<tr><td>
	There are no messages at this time.
	</td></tr>
	<? } ?>
	
</table>
</div>		


<? include("includes/footer.php"); ?>